package text.java;

import org.apache.log4j.Logger;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import pojo.SysRole;
import service.SysRoleService;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

public class SysRoleTest {
    private Logger logger = Logger.getLogger(SysRoleTest.class);
    @Test
    public void listTest(){
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationHome.xml");
        SysRoleService service = context.getBean(SysRoleService.class);
        List<SysRole> list = new ArrayList<>();
        SysRole sysRole = new SysRole();
        sysRole.setRoleName("李");
        list = service.list(sysRole);
        for (SysRole sysRole1:list){
            logger.debug(sysRole1.toString());
        }

    }
    @Test
    public void addTest(){
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationHome.xml");
        SysRoleService service = context.getBean(SysRoleService.class);
        SysRole sysRole = new SysRole();
        sysRole.setCode("2");
        sysRole.setRoleName("张三");
        sysRole.setCreatedUserId(3);
        sysRole.setCreatedTime(new Date(System.currentTimeMillis()));
        sysRole.setUpdatedUserId(1);
        sysRole.setUpdatedTime(new Date(System.currentTimeMillis()));
        boolean result = service.add(sysRole);
        logger.debug("result；"+result);
    }

}